package com.doraro.platform.module.device.controller;


import com.doraro.platform.common.utils.Result;
import com.doraro.platform.module.device.service.IRepairOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author doraro
 * @since 2019-04-21
 */
@RestController
@RequestMapping("/api/repairDevice")
@Api(description = "故障设备相关接口", tags = "device")
public class RepairDeviceRestController {
    private final IRepairOrderService orderService;

    @Autowired
    public RepairDeviceRestController(IRepairOrderService orderService) {
        this.orderService = orderService;
    }


    @GetMapping("/{deviceId}/cycleTime")
    @ApiOperation("根据故障设备编号查看的它的维修周期(天)")
    @RequiresPermissions("repairDevice:cycleTime")
    public Result getCycleTime(@PathVariable String deviceId) {
        Integer time = orderService.getCycleTime(deviceId);
        return new Result().ok().addData("time", time);
    }

    /**
     * TODO:完成
     *
     * @param rdId
     * @return
     */
    @GetMapping("/{rdId}/breakDetail")
    @ApiOperation("根据故障设备编号,查看型号设备在一定时间范围的(维修的次数,故障描述,维修花费)")
    @RequiresPermissions("repairDevice:breakDetail")
    public Result createRepairOrder(@PathVariable String rdId) {
        return new Result().ok();
    }
}

